<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html lang="zh_cn">
<head>
    <title>修改密码</title>
</head>
<body>
	<!-- 菜单及导航数据  -->
    <data id="info" nav="user" menu="password" service="用户服务" action="修改密码">

	<!-- 业务部分  开始  -->
    <div class="row wrapper border-bottom white-bg page-heading animated zoomIn min-height">
       <div class="row">
         <div class="col-lg-12">
             <div class="ibox float-e-margins">
                  <div class="ibox-title">
                      <div class="row">
                          <div class="col-sm-6 b-r"><h3 class="m-t-none m-b">修改密码</h3>
                          	<p></p>
                              <form role="form" id="updateForm">
                                  <div class="form-group"><label> 旧的密码<span class="red">*</span></label> <input type="password" name="oldpwd" id="oldpwd" placeholder="旧密码" maxlength="15" class="form-control"></div>
                                  <div class="form-group"><label> 新的密码<span class="red">*</span></label> <input type="password" name="password" id="newpwd" placeholder="新密码" maxlength="15" required="required" class="form-control"></div>
                                  <div class="form-group"><label> 确认密码<span class="red">*</span></label> <input type="password" id="pwd" placeholder="确认新密码" maxlength="15" required="required" class="form-control"></div>
                                  <div>
                                      <button id="saveBtn" class="btn btn-sm btn-primary  m-t-n-xs" type="button"><strong>保存</strong></button>
                                  </div>
                              </form>
                          </div>
                          <div class="col-sm-6"><h4>个人资料</h4>
                              <p>点击箭头可以修改您的个人信息</p>
                              <p class="text-center">
                                  <a href="${ctx}/center/user/profile/page.html"><i class="fa fa-sign-in big-icon"></i></a>
                              </p>
                          </div>
                      </div>
                  </div>
             
             </div>
         </div>
     </div>
    </div>
    <!-- 业务部分  结束  -->

	<js>
	<script src="${ctx}/resource/v2/js/common.js"></script>
	<script type="text/javascript">
    $(document).ready(function() {
    	/* 表单校验事件 */
    	$('#oldpwd').blur(function(){
    		checkPwd($('#oldpwd'));
    	});
    	$('#newpwd').blur(function(){
    		checkPwd($('#newpwd'));
    	});
    	$('#pwd').blur(function(){
    		checkPwd($('#pwd'));
    		checkPwdSame($('#newpwd'), $('#pwd'));
    	});
    	
    	/* 表单提交事件 */
	    $('#saveBtn').click(function(){
	        if(!checkPwd($('#oldpwd')) || !checkPwd($('#newpwd')) || !checkPwd($('#pwd')) ){
	        	return;
	       	}
	        $.ajax({
				url : "${ctx}/user/password/update.do",
				type : "POST",
				data : $("#updateForm").serialize(),
				dataType : "json",
				success : function(rs) {
					if(rs.flag) {
						layer.alert(rs.msg, function(){
							window.location.href = '${ctx}/user/loginPage.do';
						});
					} else {
						layer.msg(rs.msg);
					}
				}
			});
	   });
   	});
    </script>
	</js>
</body>

</html>